{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2c2ee6d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dotenv import load_dotenv\n",
    "from IPython.display import Markdown, display\n",
    "import os\n",
    "import json\n",
    "import openai"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5e6039ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "load_dotenv(override=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0d5cddd9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "open ai key is found and starts with: sk-proj-\n",
      "groq api key is found and starts with: gsk_Vopn\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from openai import OpenAI\n",
    "\n",
    "open_ai_key = os.getenv('OPENAI_API_KEY')\n",
    "groq_api_key = os.getenv('groq_api_key')\n",
    "\n",
    "if open_ai_key:\n",
    "\n",
    "    print(f'open ai key is found and starts with: {open_ai_key[:8]}')\n",
    "\n",
    "else:\n",
    "    print('open ai key not found - please check troubleshooting instructions in the setup folder')\n",
    "\n",
    "if groq_api_key:\n",
    "    print(f'groq api key is found and starts with: {groq_api_key[:8]}')\n",
    "else:\n",
    "    print('groq api key not found - please check troubleshooting guide in seyup folder')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "66ff75fc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "How can we ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients while also addressing the needs and concerns of care providers and policymakers?\n"
     ]
    }
   ],
   "source": [
    "#Setting a call for the first question\n",
    "\n",
    "message = \"Can you come up with a question that involves ethical use of AI for use in social care Settings by all stakeholders\"\n",
    "message += \"answer only with the question.No explanations\"\n",
    "\n",
    "from openai import OpenAI\n",
    "\n",
    "openai = OpenAI()\n",
    "\n",
    "message = [{\"role\":\"user\", \"content\":message}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model = \"gpt-4o-mini\",\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "mainq = response.choices[0].message.content\n",
    "print(mainq)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "fc72cbcc",
   "metadata": {},
   "outputs": [],
   "source": [
    "competitors =[]\n",
    "answers=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e978c5fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gpt-4o-mini\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
       "\n",
       "### 1. **Stakeholder Engagement:**\n",
       "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
       "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
       "\n",
       "### 2. **Ethical Frameworks:**\n",
       "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
       "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
       "\n",
       "### 3. **Privacy Protections:**\n",
       "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
       "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
       "\n",
       "### 4. **Transparency and Accountability:**\n",
       "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
       "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
       "\n",
       "### 5. **Training and Education:**\n",
       "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
       "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
       "\n",
       "### 6. **Monitoring and Feedback:**\n",
       "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
       "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
       "\n",
       "### 7. **Policy Frameworks:**\n",
       "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
       "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
       "\n",
       "### 8. **Promoting Autonomy through AI:**\n",
       "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
       "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
       "\n",
       "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#using the open ai model\n",
    "openai = OpenAI()\n",
    "model_name = \"gpt-4o-mini\"\n",
    "\n",
    "message = [{\"role\":\"user\", \"content\":mainq}]\n",
    "\n",
    "response = openai.chat.completions.create(\n",
    "    model = model_name,\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "\n",
    "\n",
    "competitors.append(model_name)\n",
    "answers.append(answer)\n",
    "\n",
    "print(model_name)\n",
    "display(Markdown(answer))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "53cc3e19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "llama3-8b-8192\n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
       "\n",
       "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
       "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
       "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
       "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
       "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
       "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
       "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
       "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
       "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
       "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
       "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
       "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
       "\n",
       "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#using the groq model\n",
    "groq = OpenAI(api_key=groq_api_key, base_url=\"https://api.groq.com/openai/v1\")\n",
    "model_name = \"llama3-8b-8192\"\n",
    "\n",
    "message = [{\"role\":\"user\",\"content\":mainq}]\n",
    "\n",
    "response = groq.chat.completions.create(\n",
    "    model = model_name,\n",
    "    messages = message\n",
    ")\n",
    "\n",
    "answer = response.choices[0].message.content\n",
    "\n",
    "#append the answer to the first list which has openai model results\n",
    "\n",
    "competitors.append(model_name)\n",
    "answers.append(answer)\n",
    "\n",
    "#print out the results of the groq model\n",
    "print(model_name)\n",
    "display(Markdown(answer))\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c091c396",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gpt-4o-mini:\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "llama3-8b-8192:\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n"
     ]
    }
   ],
   "source": [
    "#use zip to combine the two lists into one\n",
    "\n",
    "for competitor, answer in zip(competitors, answers):\n",
    "    print(f\"{competitor}:\\n\\n{answer}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ea5ccf1b",
   "metadata": {},
   "outputs": [],
   "source": [
    "#bringing it in all together\n",
    "\n",
    "together = \"\"\n",
    "for index, answer in enumerate(answers):\n",
    "    together += f\"#Response from competitor {index+1}\\n\\n\"\n",
    "    together += f\"{answer}\\n\\n\"\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "120dcb6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "#Response from competitor 1\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "\n",
      "#Response from competitor 2\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(together)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "19471a59",
   "metadata": {},
   "outputs": [],
   "source": [
    "judge = f\"\"\" You are judging a competition between {len(competitors)} different LLM models. Each model has been asked to answer the same question.\n",
    "This is the question : {mainq}\n",
    "\n",
    "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",
    "Respond with JSON, and only JSON, with the following format:\n",
    "{{\"results\":[\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}}\n",
    "\n",
    "Here are the responses from each competitor:\n",
    "\n",
    "{together}\n",
    "\n",
    "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\"\"\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "9806b0e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['gpt-4o-mini', 'llama3-8b-8192']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "competitors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9149a4ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " You are judging a competition between 2 different LLM models. Each model has been asked to answer the same question.\n",
      "This is the question : How can we ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients while also addressing the needs and concerns of care providers and policymakers?\n",
      "\n",
      "Your job is to evaluate each response for clarity and strength of argument, and rank them in order of best to worst.\n",
      "Respond with JSON, and only JSON, with the following format:\n",
      "{\"results\":[\"best competitor number\", \"second best competitor number\", \"third best competitor number\", ...]}\n",
      "\n",
      "Here are the responses from each competitor:\n",
      "\n",
      "#Response from competitor 1\n",
      "\n",
      "Ensuring that AI implementation in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs of care providers and policymakers, requires a multi-faceted approach. Here are several key strategies to achieve this balance:\n",
      "\n",
      "### 1. **Stakeholder Engagement:**\n",
      "   - **Collaborative Design:** Involve clients, care providers, policymakers, and ethicists in the design and implementation phases. This helps ensure that the technology addresses real-world needs and concerns.\n",
      "   - **User-Centered Approach:** Conduct user research to understand the experiences and preferences of clients and caregivers. This can guide the design of AI tools that enhance rather than detract from personal dignity and autonomy.\n",
      "\n",
      "### 2. **Ethical Frameworks:**\n",
      "   - **Established Guidelines:** Develop and adhere to ethical guidelines that prioritize dignity, privacy, and autonomy in AI use. Frameworks like the AI Ethics Guidelines by the EU or WHO can be references.\n",
      "   - **Regular Ethical Reviews:** Conduct ongoing assessments of AI applications in social care settings to ensure they align with ethical principles. Review processes should involve diverse stakeholders, including clients and their advocates.\n",
      "\n",
      "### 3. **Privacy Protections:**\n",
      "   - **Data Minimization:** Collect only the data necessary for the AI system to function. Avoid gathering excessive personal information that could compromise client privacy.\n",
      "   - **Informed Consent:** Ensure clients and their families are well-informed about what data is being collected, how it will be used, and their rights regarding that data. Consent should be clear, voluntary, and revocable.\n",
      "\n",
      "### 4. **Transparency and Accountability:**\n",
      "   - **Algorithm Transparency:** Make AI algorithms as transparent as possible. Clients and caregivers should understand how decisions are made and have access to explanations about AI-driven outcomes.\n",
      "   - **Accountability Mechanisms:** Establish clear lines of accountability for AI decisions in care settings. Ensure that there are channels for complaints and redress if AI systems cause harm or violate rights.\n",
      "\n",
      "### 5. **Training and Education:**\n",
      "   - **Training for Care Providers:** Equip care providers with the knowledge needed to use AI responsibly and understand its limitations. Training should include ethical implications and how to engage clients effectively.\n",
      "   - **Client Education:** Educate clients and their families on how AI tools work, emphasizing how these tools can support their care while respecting their autonomy and dignity.\n",
      "\n",
      "### 6. **Monitoring and Feedback:**\n",
      "   - **Continuous Evaluation:** Implement continuous monitoring systems to assess the impact of AI on client outcomes, dignity, and privacy. Use feedback from clients and caregivers to make improvements over time.\n",
      "   - **Adaptive Systems:** Design AI tools with adaptability in mind, allowing for real-time adjustments based on client feedback and changing conditions in social care.\n",
      "\n",
      "### 7. **Policy Frameworks:**\n",
      "   - **Supportive Regulations:** Advocate for and develop regulatory frameworks that ensure the ethical deployment of AI in social care. Such policies should protect client rights while promoting innovation.\n",
      "   - **Cross-Sector Collaboration:** Encourage partnerships between technology developers, social care providers, and policymakers to create standards and best practices for AI use in social care.\n",
      "\n",
      "### 8. **Promoting Autonomy through AI:**\n",
      "   - **Empowerment Tools:** Develop AI applications that empower clients, such as decision support systems that allow them to make informed choices about their care.\n",
      "   - **Respect Individual Preferences:** AI systems should be designed to personalize care in ways that respect and enhance each individual’s preferences and values.\n",
      "\n",
      "By integrating these strategies, we can ensure that the implementation of AI in social care settings is equitable, respectful, and aims to enhance the quality of life for clients, while also considering the needs and concerns of care providers and policymakers.\n",
      "\n",
      "#Response from competitor 2\n",
      "\n",
      "To ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers, the following measures can be taken:\n",
      "\n",
      "1. **Client-centered approach**: Engage with clients, their families, and caregivers to understand their needs, concerns, and values. Involve them in the decision-making process and ensure that AI solutions are designed to respect and uphold their dignity, privacy, and autonomy.\n",
      "2. **Data protection and security**: Implement robust data protection measures to ensure the confidentiality, integrity, and security of personal data. Comply with relevant data protection regulations, such as the General Data Protection Regulation (GDPR) and the Health Insurance Portability and Accountability Act (HIPAA).\n",
      "3. **Ethical guidelines**: Establish and implement ethical guidelines for AI development, deployment, and use in social care settings. These guidelines should be based on internationally recognized ethical principles, such as the Asilomar AI Principles and the Universal Declaration on Bioethics and Human Rights.\n",
      "4. **Transparency and explainability**: Ensure that AI systems are transparent and explainable, so that care providers, clients, and policymakers can understand how they make decisions and why. This can help build trust and confidence in AI systems.\n",
      "5. **Human oversight and review**: Establish human oversight and review mechanisms to ensure that AI decisions are accurate, fair, and respectful of clients' dignity and autonomy. This may involve reviewing AI-generated output, providing feedback, and making adjustments as needed.\n",
      "6. **Care provider training and support**: Provide training and support to care providers to help them understand how to use AI systems effectively and respectfully, while also addressing their concerns and needs.\n",
      "7. **Policymaker engagement**: Engage with policymakers and involve them in the development and implementation of AI solutions. This can help ensure that AI solutions align with policy goals and priorities, and that stakeholders are aware of the benefits and challenges associated with AI use.\n",
      "8. **Continuous evaluation and improvement**: Continuously evaluate the impact and effectiveness of AI solutions in social care settings, and make improvements based on feedback from clients, care providers, and policymakers.\n",
      "9. **Partnerships and collaborations**: Foster partnerships and collaborations between AI developers, care providers, policymakers, and other stakeholders to share knowledge, best practices, and concerns, and to accelerate the development of AI solutions that prioritize client dignity, privacy, and autonomy.\n",
      "10. **Legal and regulatory frameworks**: Ensure that legal and regulatory frameworks are in place to protect clients' rights and interests, and to promote the responsible use of AI in social care settings.\n",
      "11. **Client education and consent**: Educate clients about AI use and obtain their informed consent before using AI systems in their care. Ensure that clients understand how AI will be used, how their data will be protected, and how they can withdraw their consent if needed.\n",
      "12. **AI developers' responsibility**: Ensure that AI developers are responsible for the ethical design and deployment of AI systems, and hold them accountable for any negative consequences or biases in AI decision-making.\n",
      "\n",
      "By prioritizing these measures, it is possible to ensure that the implementation of AI in social care settings prioritizes the dignity, privacy, and autonomy of clients, while also addressing the needs and concerns of care providers and policymakers.\n",
      "\n",
      "\n",
      "\n",
      "Now respond with the JSON with the ranked order of the competitors, nothing else. Do not include markdown formatting or code blocks.\n"
     ]
    }
   ],
   "source": [
    "print(judge)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f74ac4b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "#pass the judge message into a variable\n",
    "\n",
    "judge_msg = [{\"role\":\"user\",\"content\":judge}]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "999504f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"results\":[\"1\",\"2\"]}\n"
     ]
    }
   ],
   "source": [
    "response = openai.chat.completions.create(\n",
    "    model = \"gpt-4o-mini\",\n",
    "    messages = judge_msg\n",
    ")\n",
    "result = (response.choices[0].message.content)\n",
    "\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "a6b15c47",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Turn the response into a result\n",
    "result_dict = json.loads(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "738f77d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'results': ['1', '2']}"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "01355ac8",
   "metadata": {},
   "outputs": [],
   "source": [
    "rank = jsonresult[\"results\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "968594de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rank"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "d9b89347",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rank 1: gpt-4o-mini\n",
      "Rank 2: llama3-8b-8192\n"
     ]
    }
   ],
   "source": [
    "for index, result in enumerate(rank):\n",
    "    competitor = competitors[int(result)-1]\n",
    "    print(f\"Rank {index+1}: {competitor}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7f41158",
   "metadata": {},
   "source": [
    "Thank you Ed for supporting me in making my  first contribution to the community"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
